
public class Tower {
	static final int maxlevel = 5;
	int id;
	
	public int level = 0;
	public int peopleCount[];
	public int type = 0;
	public int leftUpgrade = -1;
	int x, y;
	
	int[] distances;
	
	
	public Tower(int count, int id, int type, int x, int y, int[] distances) {
		peopleCount = new int[count + 1];
		this.type = type;
		this.id = id;
		this.x = x;
		this.y = y;
		this.distances = distances;
	}

	int countMaxPeople() {
		return 100 + level * 20;
	}
	
	int needtoUpgrade() {
		return (level == maxlevel || leftUpgrade >= 0) ? (int)2e9 : (countMaxPeople() * 2 / 3);
	}
	
	int countBirth() {
		return level + 1;
	}
	
	int countDeath() {
		return 2 * countBirth();
	}
	
	int countWarDeath() {
		return (countDeath() - countBirth()) + (maxlevel - level + 1);
	}
	
	int getDist(Tower t) {
		return distances[t.id];
	}
}
